import * as React from 'react';
import { inject, observer } from 'mobx-react'
import { Button, } from 'antd';
import { baseURL } from "../../config/config"

interface IAppProps {
    userStore?: any,
    url: string,
}

@inject("userStore")
@observer
class IExport extends React.Component<IAppProps, {}> {
    state = {
        url: "",
    }
    componentDidMount() {
        const { userInfo } = this.props.userStore;
        const { url } = this.props;
        this.setState({
            url: `${baseURL}${url}?X-Auth-User=${userInfo.username}&X-Auth-Token=${userInfo.token}`
        })
    }
    
    public render() {

        return (
            <a
                href={this.state.url}
                download="aaa.xls"
            >
                <Button type="primary">导出</Button>
            </a>
        );
    }

}




export default IExport;
